package com.yanqu.road.server.cmd.activity.cross;

import com.yanqu.road.pb.activity.CrossActivityRankProto;
import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_CROSS_ACTIVITY_RANK_LIST, desc = "获取跨服排行榜数据")
public class CrossActivityRankListCmd extends AbstractCommand {

    private int activityId;
    private int bigRankType;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        RankProto.RankListReqMsg reqMsg = RankProto.RankListReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getRankType();
        bigRankType = reqMsg.getBigRankType();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		/*RankProto.RankListRespMsg.Builder respMsg = RankProto.RankListRespMsg.newBuilder();
		RankProto.RankListMsg.Builder rankListMsg = CrossDataMgr.getCrossRankActivityRankMsg(activityId);
		ActivityInfo activityInfo = NormalActivityMgr.getActivityInfo(activityId);
		int maxRank = GameConfig.RANK_DEFAULT_MAX_COUNT;
		if(null != activityInfo) {
			int conditionType = ActivityHelper.getCrossRankConditionType(activityInfo.getSchoolType(), activityInfo.getChildType());
			maxRank = ActivityHelper.getMaxRankByConditionType(conditionType, NormalActivityMgr.getActivityConditionInfoList(activityInfo.getActivityId()));
		}
		while (null != rankListMsg.getRankListList() && rankListMsg.getRankListCount() > maxRank){
			rankListMsg.removeRankList(rankListMsg.getRankListCount() - 1);
		}
		respMsg.setRankList(rankListMsg);
		respMsg.setRankType(activityId);
		respMsg.setMyRank(ActivityMgr.getMyCrossRank(player.getUserId(), rankListMsg));
		respMsg.setBigRankType(bigRankType);*/
        CrossActivityRankProto.CrossActivityRankReqMsg.Builder respMsg = CrossActivityRankProto.CrossActivityRankReqMsg.newBuilder();
        respMsg.setActivityId(activityId);
        respMsg.setBigRankType(bigRankType);
        player.sendPacket(Protocol.C2_CROSS_GET_ACTIVITY_RANK, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
